#include <cstdio>
#include <queue>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int k[11000];
int vis[11000];
int n,a,b;
struct node
{
	int step;
	int to;
}m,m2;
queue<node>qe;
int bfs()
{
	int temp1,temp2;
	vis[a]=1;
	while(!qe.empty())
	{
		m = qe.front();
		qe.pop();
		if(m.to == b)
		{
			return m.step;
		}
		else
		{
			m2 = m;
			temp1 = m.to+k[m.to];//up
			temp2 = m2.to-k[m2.to];//draw
			if(temp1<=n&&temp1>=1&&!vis[temp1])
			{
				vis[temp1]=1;
				m.to=temp1;
				m.step++;
				qe.push(m);
			}
			if(temp2<=n&&temp2>=1&&!vis[temp2])
			{
				vis[temp2]=1;
				m2.to=temp2;
				m2.step++;
				qe.push(m2);
			}
		}
	}
	return -1;
}
int main()
{
	int ans;
	while(scanf("%d",&n)&&n)
	{
		while(!qe.empty())
		{
			qe.pop();
		}
		node m;
		memset(k,0,sizeof(k));
		memset(vis,0,sizeof(vis));
		scanf("%d %d",&a,&b);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&k[i]);
		}
		m.to = a;
		m.step = 0;
		qe.push(m);
		ans = bfs();
		printf("%d\n",ans);
	}
} 
